<?php

/**
 * This is the model class for table "billet_incident".
 *
 * The followings are the available columns in table 'billet_incident':
 * @property integer $ID_BILLET_INCIDENT
 * @property integer $ID_PROBLEME_LOGICIEL
 * @property integer $ID_POSTE
 * @property integer $ID_EMETTEUR
 * @property integer $ID_PROBLEME_MATERIEL
 * @property string $DESCRIPTION_PROBLEME
 * @property string $URGENCE
 * @property string $DATE_OUVERTURE
 * @property string $DATE_FERMETURE
 * @property string $DATE_FIN_PREVUE
 * @property string $PIECE_JOINTE
 * @property integer $RESOLU
 *
 * The followings are the available model relations:
 * @property Affectation[] $affectations
 * @property Poste $iDPOSTE
 * @property ProblemeLogiciel $iDPROBLEMELOGICIEL
 * @property ProblemeMateriel $iDPROBLEMEMATERIEL
 * @property Emetteur $iDEMETTEUR
 * @property InterventionsRealisees[] $interventionsRealisees
 */
class BilletIncidentAdmin extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BilletIncidentAdmin the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'billet_incident';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ID_POSTE, ID_EMETTEUR, DESCRIPTION_PROBLEME, DATE_FIN_PREVUE', 'required'),
			array('ID_PROBLEME_LOGICIEL, ID_POSTE, ID_EMETTEUR, ID_PROBLEME_MATERIEL', 'numerical', 'integerOnly'=>true),
			array('URGENCE,RESOLU', 'length', 'max'=>50),
			array('DATE_FIN_PREVUE', 'date', 'format'=>array('dd/MM/yyyy')),
			array('DATE_FERMETURE, DATE_FIN_PREVUE, PIECE_JOINTE', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_BILLET_INCIDENT, ID_PROBLEME_LOGICIEL, ID_POSTE, ID_EMETTEUR, ID_PROBLEME_MATERIEL, DESCRIPTION_PROBLEME, URGENCE, DATE_OUVERTURE, DATE_FERMETURE, DATE_FIN_PREVUE, PIECE_JOINTE, RESOLU', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'affectations' => array(self::HAS_MANY, 'Affectation', 'ID_BILLET_INCIDENT'),
			'iDPOSTE' => array(self::BELONGS_TO, 'Poste', 'ID_POSTE'),
			'iDPROBLEMELOGICIEL' => array(self::BELONGS_TO, 'ProblemeLogiciel', 'ID_PROBLEME_LOGICIEL'),
			'iDPROBLEMEMATERIEL' => array(self::BELONGS_TO, 'ProblemeMateriel', 'ID_PROBLEME_MATERIEL'),
			'iDEMETTEUR' => array(self::BELONGS_TO, 'Emetteur', 'ID_EMETTEUR'),
			'interventionsRealisees' => array(self::HAS_MANY, 'InterventionsRealisees', 'ID_BILLET_INCIDENT'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_BILLET_INCIDENT' => 'Id Billet Incident',
			'ID_PROBLEME_LOGICIEL' => 'Id Probleme Logiciel',
			'ID_POSTE' => 'Id Poste',
			'ID_EMETTEUR' => 'Id Emetteur',
			'ID_PROBLEME_MATERIEL' => 'Id Probleme Materiel',
			'DESCRIPTION_PROBLEME' => 'Description Probleme',
			'URGENCE' => 'Urgence',
			'DATE_OUVERTURE' => 'Date Ouverture',
			'DATE_FERMETURE' => 'Date Fermeture',
			'DATE_FIN_PREVUE' => 'Date Fin Prevue',
			'PIECE_JOINTE' => 'Piece Jointe',
			'RESOLU' => 'Resolu',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_BILLET_INCIDENT',$this->ID_BILLET_INCIDENT);
		$criteria->compare('ID_PROBLEME_LOGICIEL',$this->ID_PROBLEME_LOGICIEL);
		$criteria->compare('ID_POSTE',$this->ID_POSTE);
		$criteria->compare('ID_EMETTEUR',$this->ID_EMETTEUR);
		$criteria->compare('ID_PROBLEME_MATERIEL',$this->ID_PROBLEME_MATERIEL);
		$criteria->compare('DESCRIPTION_PROBLEME',$this->DESCRIPTION_PROBLEME,true);
		$criteria->compare('URGENCE',$this->URGENCE,true);
		$criteria->compare('DATE_OUVERTURE',$this->DATE_OUVERTURE,true);
		$criteria->compare('DATE_FERMETURE',$this->DATE_FERMETURE,true);
		$criteria->compare('DATE_FIN_PREVUE',$this->DATE_FIN_PREVUE,true);
		$criteria->compare('PIECE_JOINTE',$this->PIECE_JOINTE,true);
		$criteria->compare('RESOLU',$this->RESOLU);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}